﻿<%@ Page Title="" Language="C#" MasterPageFile="~/manager/page/ManagerMasterPage.Master" AutoEventWireup="true" CodeBehind="event.aspx.cs" Inherits="Com.Web.coffinegurunaru.manager.Event._event" %>
<%@ Register TagPrefix="UC" TagName="Menu" Src="~/manager/event/menu.ascx" %>
<asp:Content ID="Content1" ContentPlaceHolderID="phHead" runat="server"></asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="phContent" runat="server">
<hr />
<br />
<table width="100%">
<tr>
	<td valign="top" width="100">
		<UC:Menu ID="Menu1" SubPageType=1 runat="server" />
	</td>
	<td style="width:20px;"></td>
	<td>


<div id="m_Input">
<table cellpadding="0" cellspacing="1" border="0" style="background-color:Olive; width:100%;">
<tr>
	<td style="background-color:#eeeeee; width:200px; text-align:center;">이벤트 시작일</td>
	<td style="background-color:#ffffff;"><input type="text" class="m_EventStart" /></td>
</tr>
<tr>
	<td style="background-color:#eeeeee; width:200px; text-align:center;">이벤트 종료일</td>
	<td style="background-color:#ffffff;"><input type="text" class="m_EventEnd" /></td>
</tr>
<tr>
	<td style="background-color:#eeeeee; width:200px; text-align:center;">이벤트 발표일</td>
	<td style="background-color:#ffffff;"><input type="text" class="m_PublicationDate" /></td>
</tr>
<tr>
	<td style="background-color:#eeeeee; width:200px; text-align:center;">리스트 이미지</td>
	<td style="background-color:#ffffff;"><input type="text" class="m_ImageURL" readonly="readonly" style="width:300px;" /><input type="button" value="이미지" class="m_btnImageURL"/></td>
</tr>
<tr>
	<td style="background-color:#eeeeee; width:200px; text-align:center;">보기 이미지</td>
	<td style="background-color:#ffffff;"><input type="text" class="m_BigImageUrl" readonly="readonly" style="width:300px;" /><input type="button" value="이미지" class="m_btnBigImageUrl"/></td>
</tr>
<tr>
	<td style="background-color:#eeeeee; width:200px; text-align:center;">보기 이미지</td>
	<td style="background-color:#ffffff;"><input type="text" class="m_BigImageUrl2" style="width:300px;" /><input type="button" value="이미지" class="m_btnBigImageUrl2"/></td>
</tr>
<tr>
	<td style="background-color:#eeeeee; width:200px; text-align:center;">보기 이미지</td>
	<td style="background-color:#ffffff;"><input type="text" class="m_BigImageUrl3" style="width:300px;" /><input type="button" value="이미지" class="m_btnBigImageUrl3"/></td>
</tr>
<tr>
	<td style="background-color:#eeeeee; width:200px; text-align:center;">보기 이미지</td>
	<td style="background-color:#ffffff;"><input type="text" class="m_BigImageUrl4" style="width:300px;" /><input type="button" value="이미지" class="m_btnBigImageUrl4"/></td>
</tr>
<tr>
	<td style="background-color:#eeeeee; width:200px; text-align:center;">보기 이미지</td>
	<td style="background-color:#ffffff;"><input type="text" class="m_BigImageUrl5" style="width:300px;" /><input type="button" value="이미지" class="m_btnBigImageUrl5"/></td>
</tr>
<tr>
	<td style="background-color:#eeeeee; width:200px; text-align:center;">제목</td>
	<td style="background-color:#ffffff;"><input type="text" class="m_Title" style="width:300px;" /></td>
</tr>
<tr>
	<td style="background-color:#eeeeee; width:200px; text-align:center;">내용정렬</td>
	<td style="background-color:#ffffff;"><select class="m_CodeContent"><option value="1">왼쪽</option><option value="2">중간</option><option value="3">오른쪽</option></select></td>
</tr>
<tr>
	<td style="background-color:#eeeeee; width:200px; text-align:center;">내용</td>
	<td style="background-color:#ffffff;"><textarea class="m_Content" rows="7" cols="40"></textarea></td>
</tr>
<tr>
	<td colspan="2" style="background-color:#ffffff; text-align:center;"><input type="button" class="m_btnConfirm" value="등록"/></td>
</tr>
</table>
</div>
<br />
<table>
<tr>
	<td>
		<select id="m_SearchType">
			<option value="0">전체</option>
			<option value="1">진행중</option>
		</select>
	</td>
</tr>
<tr>
	<td style="text-align:center;" valign="top">
		<div id="m_List"></div><br />
		<div id="m_Pager"></div>
	</td>
	<td style="width:20px;">&nbsp;</td>
	<td valign="top"><div id="m_Viewer"></div></td>
</tr>
</table>


<script language="javascript" type="text/javascript">
(function($) {
	$.CoffineEvent = {};
	
	$.CoffineEvent = {
		Init : function() {
			$("#m_SearchType").change(function() {
				$.CoffineEvent.GetList();
			});
			
			$("#m_Input input.m_btnImageURL").click(function() {
				$.CoffineEvent.FileCreateOpen_LIST();
			});
			
			$("#m_Input input.m_btnBigImageUrl").click(function() {
				$.CoffineEvent.FileCreateOpen_VIEW("$.CoffineEvent.FileCreateOpen_VIEW1_Callback");
			});
			
			$("#m_Input input.m_btnBigImageUrl2").click(function() {
				$.CoffineEvent.FileCreateOpen_VIEW("$.CoffineEvent.FileCreateOpen_VIEW2_Callback");
			});
			$("#m_Input input.m_btnBigImageUrl3").click(function() {
				$.CoffineEvent.FileCreateOpen_VIEW("$.CoffineEvent.FileCreateOpen_VIEW3_Callback");
			});
			$("#m_Input input.m_btnBigImageUrl4").click(function() {
				$.CoffineEvent.FileCreateOpen_VIEW("$.CoffineEvent.FileCreateOpen_VIEW4_Callback");
			});
			$("#m_Input input.m_btnBigImageUrl5").click(function() {
				$.CoffineEvent.FileCreateOpen_VIEW("$.CoffineEvent.FileCreateOpen_VIEW5_Callback");
			});
			
			
			$("#m_Pager").pager({
				pageSize : 5,
				useCallback : true,
				pageNo : 1,
				callback:function(pageNo) {
					$.CoffineEvent.GetList();
				}
			});
			
			$("#m_Input input.m_btnConfirm").click(function() {
				$.CoffineEvent.Create();
			});
			
			$.CoffineEvent.GetList();
		},
		
		FileCreateOpen_LIST : function()
		{
			$.manager.fileopen(8, "$.CoffineEvent.FileCreateOpen_LIST_Callback");
		},

		FileCreateOpen_LIST_Callback : function( fileurl )
		{
			$("#m_Input input.m_ImageURL").val( fileurl );
		},

		FileCreateOpen_VIEW : function(callback)
		{
			$.manager.fileopen(9, callback);
		},

		FileCreateOpen_VIEW1_Callback : function( fileurl )
		{
			$("#m_Input input.m_BigImageUrl").val( fileurl );
		},
		
		FileCreateOpen_VIEW2_Callback : function( fileurl )
		{
			$("#m_Input input.m_BigImageUrl2").val( fileurl );
		},
		FileCreateOpen_VIEW3_Callback : function( fileurl )
		{
			$("#m_Input input.m_BigImageUrl3").val( fileurl );
		},
		FileCreateOpen_VIEW4_Callback : function( fileurl )
		{
			$("#m_Input input.m_BigImageUrl4").val( fileurl );
		},
		FileCreateOpen_VIEW5_Callback : function( fileurl )
		{
			$("#m_Input input.m_BigImageUrl5").val( fileurl );
		},
		
		
		FileModifyOpen_LIST : function()
		{
			$.manager.fileopen(8, "$.CoffineEvent.FileModifyOpen_LIST_Callback");
		},

		FileModifyOpen_LIST_Callback : function( fileurl )
		{
			$("#m_Viewer input.m_ImageURL").val( fileurl );
		},

		FileModifyOpen_VIEW : function(callback)
		{
			$.manager.fileopen(9, callback);
		},

		FileModifyOpen2_VIEW1_Callback : function( fileurl )
		{
			$("#m_Viewer input.m_BigImageUrl").val( fileurl );
		},
		
		FileModifyOpen2_VIEW2_Callback : function( fileurl )
		{
			$("#m_Viewer input.m_BigImageUrl2").val( fileurl );
		},
		
		FileModifyOpen2_VIEW3_Callback : function( fileurl )
		{
			$("#m_Viewer input.m_BigImageUrl3").val( fileurl );
		},
		
		FileModifyOpen2_VIEW4_Callback : function( fileurl )
		{
			$("#m_Viewer input.m_BigImageUrl4").val( fileurl );
		},
		
		FileModifyOpen2_VIEW5_Callback : function( fileurl )
		{
			$("#m_Viewer input.m_BigImageUrl5").val( fileurl );
		},
		
		
		GetList : function() {
			var SearchType = $("#m_SearchType").val();
			$("#m_List").ajaxNet(
			"/manager/Event/eventMethod.aspx?_vb=GetList",
			{
				"SearchType" : SearchType
			,	"PageNo" : $("#m_Pager").pager("option", "currentPageNo")
			,	"PageSize" : $("#m_Pager").pager("option", "pageSize")
			}, function(results, context)
			{
				$("#m_List").html( results[0] );
				$("#m_Pager").pager("update", results[1]);
				$("#m_List").find("input.m_btnViewer").val("수정").click(function() {
					var $tr = $(this).closest("tr");
					var data = $tr.tagdata();
					$.CoffineEvent.GetInfo(data.EventSN);
				});
			});
		},
		
		GetInfo : function( EventSN ) {
			$("#m_Viewer").ajaxNet(
			"/manager/Event/eventMethod.aspx?_vb=GetInfo",
			{
				"EventSN" : EventSN
			}, function(results, context)
			{
				$("#m_Viewer").html( results );
				$("#m_Viewer").find("input.m_btnConfirm").click(function() {
					$.CoffineEvent.Modify(EventSN);
				});

				$("#m_Viewer").find("input.m_btnRemove").click(function() {
					$.CoffineEvent.Remove(EventSN);
				});
				
				$("#m_Viewer input.m_btnImageURL").click(function() {
					$.CoffineEvent.FileModifyOpen_LIST();
				});
				
				$("#m_Viewer input.m_btnBigImageUrl").click(function() {
					$.CoffineEvent.FileModifyOpen_VIEW("$.CoffineEvent.FileModifyOpen2_VIEW1_Callback");
				});
				
				$("#m_Viewer input.m_btnBigImageUrl2").click(function() {
					$.CoffineEvent.FileModifyOpen_VIEW("$.CoffineEvent.FileModifyOpen2_VIEW2_Callback");
				});
				
				$("#m_Viewer input.m_btnBigImageUrl3").click(function() {
					$.CoffineEvent.FileModifyOpen_VIEW("$.CoffineEvent.FileModifyOpen2_VIEW3_Callback");
				});
				
				$("#m_Viewer input.m_btnBigImageUrl4").click(function() {
					$.CoffineEvent.FileModifyOpen_VIEW("$.CoffineEvent.FileModifyOpen2_VIEW4_Callback");
				});
				
				$("#m_Viewer input.m_btnBigImageUrl5").click(function() {
					$.CoffineEvent.FileModifyOpen_VIEW("$.CoffineEvent.FileModifyOpen2_VIEW5_Callback");
				});
			});
		},
		
		Remove : function(EventSN) {
			if ( confirm("정말로 삭제하시겠습니까?") ) {
				$("#m_Viewer").ajaxNet(
				"/manager/event/eventmethod.aspx?_vb=Remove",
				{
					"EventSN" : EventSN
				}, function(results, context)
				{
					location.href = location.href;
					alert('삭제되었습니다..');
				});
			}
		},
		
		Create : function() {
			var eventStartString = $("#m_Input input.m_EventStart").val();
			var eventEndString = $("#m_Input input.m_EventEnd").val();
			var PublicationDateString = $("#m_Input input.m_PublicationDate").val();
			var imageUrl = $("#m_Input input.m_ImageURL").val();
			var bigImageUrl = $("#m_Input input.m_BigImageUrl").val();
			var title = $("#m_Input input.m_Title").val();
			var content = $("#m_Input textarea.m_Content").val();
			
			var bigImageUrl2 = $("#m_Input input.m_BigImageUrl2").val();
			var bigImageUrl3 = $("#m_Input input.m_BigImageUrl3").val();
			var bigImageUrl4 = $("#m_Input input.m_BigImageUrl4").val();
			var bigImageUrl5 = $("#m_Input input.m_BigImageUrl5").val();
			
			var codeContent = $("#m_Input select.m_CodeContent").val();
			
			if ( $.trim(eventStartString) == "" ) {
				alert( "시작일을 입력하세요");
				return false;
			}
			if ( $.trim(eventEndString) == "" ) {
				alert( "종료일을 입력하세요");
				return false;
			}
			if ( $.trim(PublicationDateString) == "" ) {
				alert( "발표일을 입력하세요");
				return false;
			}
			if ( $.trim(imageUrl) == "" ) {
				alert( "이미지를 입력하세요");
				return false;
			}
			if ( $.trim(bigImageUrl) == "" ) {
				alert( "이미지를 입력하세요");
				return false;
			}
			if ( $.trim(title) == "" ) {
				alert( "제목을 입력하세요");
				return false;
			}

			$("div.inputForm").ajaxNet(
			"/manager/event/eventmethod.aspx?_vb=Create",
			{
				"StartDateString" : eventStartString,
				"EndDateString" : eventEndString,
				"PublicationDateString" : PublicationDateString,
				"ImageUrl" : imageUrl,
				"BigImageUrl" : bigImageUrl,
				"Title" : title,
				"Content" : content,
				"BigImageUrl2" : bigImageUrl2,
				"BigImageUrl3" : bigImageUrl3,
				"BigImageUrl4" : bigImageUrl4,
				"BigImageUrl5" : bigImageUrl5,
				"CodeContent" : codeContent
			}, function(results, context)
			{
				alert('추가되었습니다.');
				location.href = location.href;
			});
		},
		
		Modify : function(EventSN) {
			var eventStartString = $("#m_Viewer input.m_EventStart").val();
			var eventEndString = $("#m_Viewer input.m_EventEnd").val();
			var PublicationDateString = $("#m_Viewer input.m_PublicationDate").val();
			var imageUrl = $("#m_Viewer input.m_ImageURL").val();
			var bigImageUrl = $("#m_Viewer input.m_BigImageUrl").val();
			var title = $("#m_Viewer input.m_Title").val();
			var content = $("#m_Viewer textarea.m_Content").val();
			
			var bigImageUrl2 = $("#m_Viewer input.m_BigImageUrl2").val();
			var bigImageUrl3 = $("#m_Viewer input.m_BigImageUrl3").val();
			var bigImageUrl4 = $("#m_Viewer input.m_BigImageUrl4").val();
			var bigImageUrl5 = $("#m_Viewer input.m_BigImageUrl5").val();
			
			var codeContent = $("#m_Viewer select.m_CodeContent").val();

			
			if ( $.trim(eventStartString) == "" ) {
				alert( "시작일을 입력하세요");
				return false;
			}
			if ( $.trim(eventEndString) == "" ) {
				alert( "종료일을 입력하세요");
				return false;
			}
			if ( $.trim(PublicationDateString) == "" ) {
				alert( "발표일을 입력하세요");
				return false;
			}
			if ( $.trim(imageUrl) == "" ) {
				alert( "이미지를 입력하세요");
				return false;
			}
			if ( $.trim(bigImageUrl) == "" ) {
				alert( "이미지를 입력하세요");
				return false;
			}
			if ( $.trim(title) == "" ) {
				alert( "제목을 입력하세요");
				return false;
			}
		
			$("div.inputForm").ajaxNet(
			"/manager/event/eventmethod.aspx?_vb=Modify",
			{
				"EventSN" : EventSN,
				"StartDateString" : eventStartString,
				"EndDateString" : eventEndString,
				"PublicationDateString" : PublicationDateString,
				"ImageUrl" : imageUrl,
				"BigImageUrl" : bigImageUrl,
				"Title" : title,
				"Content" : content,
				"BigImageUrl2" : bigImageUrl2,
				"BigImageUrl3" : bigImageUrl3,
				"BigImageUrl4" : bigImageUrl4,
				"BigImageUrl5" : bigImageUrl5,
				"CodeContent" : codeContent
				
			}, function(results, context)
			{
				alert('변경 되었습니다.');
				location.href = location.href;
			});
		}
	}
	
	$(function() {
		$.CoffineEvent.Init();
	});
})(jQuery);
</script>














	</td>
</tr>
</table>
</asp:Content>
